package net.mindView.utils;

public class Stack extends java.util.Stack {
    public void evaluation(String s){
        char[] chars = s.toCharArray();
        for(int i=0;i<chars.length;i++){
            switch (chars[i]){
                case '+':
                    if(chars[i+1]=='+'||chars[i+1]=='-'){
                        push(" ");
                    }else{
                        push(chars[++i]);
                    }
                    break;
                case '-':
                    if(!isEmpty()){
                        System.out.print(pop() + " ");
                    }else{
                        System.out.println("Error");
                    }
                    break;
                default:
                    System.out.println("Error");
            }
        }
    }
}
